<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<h1>登录页面</h1>
用户名:<input type="text" id="username">
密码:<input type="text" id="password">
<button id="submit" name="submit">登录</button>
<script>
    $(document).ready(function () {
        $("button").click(function () {
            let username = $("#username").val();
            let password = $("#password").val();
            $.ajax({
                type: "POST",
                url: "http://localhost:8080/login",
                data: {
                    username: username,
                    password: password
                },
                success: function () {
                    alert("登录成功");
                    window.location='/'
                },
                error: function (){
                    alert("用户名或者密码错误");
                }
            });
        });
    });
</script>
</body>
</html>